home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-2.iso / extra_2 / nadir11.zip / CLIENT.N < prev    next >
Text File  |  1995-11-08  |  9KB  |  248 lines

  1. If(0)
  2.  
  3.     DATA STORED IN UNIV FILE FOR CLIENTS
  4.  
  5.     code is the client code
  6.  
  7.     clnt^[code]^attn    = The attention to string
  8.     clnt^[code]^add1    = Client address line 1
  9.     clnt^[code]^add2    = Client address line 2
  10.     clnt^[code]^add3    = Client address line 3
  11.     clnt^[code]^add4    = Client address line 4
  12.  
  13.     clnt_code^[code]    = The Clients name
  14.  
  15.     DATA STORED IN UNIV FILE FOR CLIENT BRANCHES
  16.  
  17.     client is the client code that the branch belongs to
  18.     code is the branch code
  19.  
  20.     clbr^[client]^[code]^attn   = The attention to string
  21.     clbr^[client]^[code]^add1   = Client branch address line 1
  22.     clbr^[client]^[code]^add2   = Client branch address line 2
  23.     clbr^[client]^[code]^add3   = Client branch address line 3
  24.     clbr^[client]^[code]^add4   = Client branch address line 4
  25.  
  26.     clbr_code^[client]^[code]   = Client branch name
  27.  
  28. Endif
  29. Define ClientSearchCode(key, type) {
  30.     Explode(key, "^", &code);
  31.     if (type != "s")
  32.         return code;
  33.     return StrCat(code, "\t", univ^clnt_code^[code]);
  34. }
  35. Define ClientMaintScr() {
  36.     scr = SdCreate(, -1, -1, 18, 72, "Client Maintenance");
  37.  
  38.     SdPrompt(scr, 1,  1, "Client Code     :");
  39.     SdCombo(scr, "code",  0,  1, 19, 12, 10, , 
  40.                     "univ^clnt_code^", 133, "ClientSearchCode", 62, , 134);
  41.     SdFieldCols(scr, "code", 10);
  42.     SdPrompt(scr, 3,  1, "Client Name     :");
  43.     SdString(scr, "desc", 0,  3, 19, 50);
  44.     SdPrompt(scr, 5,  1, "Attention       :");
  45.     SdString(scr, "attn", 0,  5, 19, 50);
  46.     SdPrompt(scr, 7,  1, "Address         :");
  47.     SdString(scr,"add1", 0,  7, 19, 50);
  48.     SdString(scr,"add2", 0,  8, 19, 50);
  49.     SdString(scr,"add3", 0,  9, 19, 50);
  50.     SdString(scr,"add4", 0, 10, 19, 50);
  51.  
  52.     SdButton(scr, "ok",   0, 16, 16, 10, "Maint", "m", 1);
  53.     SdButton(scr, "bra",  0, 16, 29, 10, "Branches", "b", 112);
  54.     SdButton(scr, "del",  0, 16, 42, 10, "Delete", "d", 114);
  55.     SdButton(scr, "can",  1, 16, 55, 10, "Cancel", "", 2);
  56.     return scr;
  57. }
  58. Define ClientDeleteBranches(code) {
  59.     while (1) {
  60.         Explode(next(univ^clbr_code^[code]^[branch]),"^", &p1, &p2, &branch);
  61.         if (p2 != code || p1 != "clbr_code")
  62.             break;
  63.         ClientBranchDelete(code, branch);
  64.     }
  65. }
  66. Define ClientDelete(code) {
  67.     while(field = NextField("univ", "clnt", code, field))
  68.         univ^clnt^[code]^[field] = "";
  69.     univ^clnt_code^[code] = "";
  70. }
  71. Define ClientMaint() {
  72.     scr = ClientMaintScr();
  73.     mode = 1;
  74.     cursor = "";
  75.     while (1) {
  76.         if (!cursor) {
  77.             if (mode) {
  78.                 SdModeSet(scr, 0);
  79.                 SdModeSet(scr, 1, "code", "bra", "del", "can");
  80.                 SdButton(scr, "ok",   1, 16, 16, 10, "Maint", "m", 1);
  81.             }
  82.             else {
  83.                 SdModeSet(scr, 1);
  84.                 SdModeSet(scr, 0, "code", "bra", "del");
  85.                 if (univ^clnt_code^[code])
  86.                     SdButton(scr, "ok",   1, 16, 16, 10, "Modify", "m", 1);
  87.                 else
  88.                     SdButton(scr, "ok",   1, 16, 16, 10, "Add", "a", 1);
  89.             }
  90.             SdFieldVar(scr, "code",     code,
  91.                             "desc",     &univ^clnt_code^[code],
  92.                             "attn",     &univ^clnt^[code]^attn,
  93.                             "add1",     &univ^clnt^[code]^add1,
  94.                             "add2",     &univ^clnt^[code]^add2,
  95.                             "add3",     &univ^clnt^[code]^add3,
  96.                             "add4",     &univ^clnt^[code]^add4);
  97.         }
  98.         cmd = SdEdit(scr, cursor);
  99.         if (mode) {
  100.             Explode(SdFieldGet(scr, "code"), "^", &code);
  101.             if (cmd == 133)             /* action on the combo box */
  102.                 continue;
  103.             else if (cmd == 2 || cmd == 3)
  104.                 break;
  105.             else if (cmd != 1 && cmd != 134) {
  106.                 if (!univ^clnt_code^[code]) {
  107.                     MsgWait("", "Client Code does not exist.");
  108.                     continue;
  109.                 }
  110.                 if (cmd == 114) {       /* delete */
  111.                     if ((cmd = MsgYesNoCancel("", 
  112.                                 "Delete " . code . ", are you sure ?")) 
  113.                                 && cmd == 2) {      /* yes hit ? */
  114.                         ClientDeleteBranches(code);
  115.                         ClientDelete(code);
  116.                     }
  117.                 }
  118.                 else if (cmd == 112)    /* branches */
  119.                     ClientBranchMaint(code);
  120.                 continue;
  121.             }
  122.             mode = 0;                   /* means change details */
  123.         }
  124.         else {
  125.             if (cmd == 1) {
  126.                 if (!SdFieldGet(scr, "desc")) {
  127.                     MsgWait("", "Client Name must be entered.");
  128.                     cursor = "desc";
  129.                     continue;
  130.                 }
  131.                 SdUpdate(scr);
  132.             }
  133.             else if (cmd == 3) 
  134.                 break;
  135.             mode = 1;                   /* means do next selection */
  136.         }
  137.         cursor = "";
  138.     }
  139.     SdDestroy(scr);
  140. }
  141. Define ClientBranchSearchCode(key, type, prefix) {
  142.     Explode(key, "^", &code);
  143.     if (type != "s")
  144.         return code;
  145.     return StrCat(code, "\t", univ^[prefix][code]);
  146. }
  147. Define ClientBranchMaintScr(client) {
  148.     scr = SdCreate(, -1, -1, 18, 72, 
  149.                    StrCat("Client Branch Maintenance - ", client));
  150.  
  151.     SdPrompt(scr, 1,  1, "Branch Code     :");
  152.     SdCombo(scr, "code",  0,  1, 19, 12, 10, "", 
  153.                             StrCat("univ^clbr_code^", client, "^"), 
  154.                             133, "ClientBranchSearchCode", 62);
  155.     SdFieldCols(scr, "code", 10);
  156.     SdPrompt(scr, 3,  1, "Branch Name     :");
  157.     SdString(scr, "desc", 0,  3, 19, 50);
  158.     SdPrompt(scr, 5,  1, "Attention       :");
  159.     SdString(scr, "attn", 0,  5, 19, 50);
  160.     SdPrompt(scr, 7,  1, "Address         :");
  161.     SdString(scr,"add1", 0,  7, 19, 50);
  162.     SdString(scr,"add2", 0,  8, 19, 50);
  163.     SdString(scr,"add3", 0,  9, 19, 50);
  164.     SdString(scr,"add4", 0, 10, 19, 50);
  165.  
  166.     SdButton(scr, "ok",   0, 16, 29, 10, "Maint", "m", 1);
  167.     SdButton(scr, "del",  0, 16, 42, 10, "Delete", "d", 114);
  168.     SdButton(scr, "can",  1, 16, 55, 10, "Cancel", "", 2);
  169.     return scr;
  170. }
  171. Define ClientBranchDelete(client, code) {
  172.     while(1) {
  173.         Explode(next(univ^clbr^[client]^[code]^[field]), "^",
  174.                             &p1, &p2, &p3, &field);
  175.         if (p3 != code || p2 != client || p1 != "clbr")
  176.             break;
  177.         univ^clbr^[client]^[code]^[field] = "";
  178.     }
  179.     univ^clbr_code^[client]^[code] = "";
  180. }
  181. Define ClientBranchMaint(client) {
  182.     scr = ClientBranchMaintScr(client);
  183.     mode = 1;
  184.     cursor = "";
  185.     while (1) {
  186.         if (!cursor) {
  187.             if (mode) {
  188.                 SdModeSet(scr, 0);
  189.                 SdModeSet(scr, 1, "code", "del", "can");
  190.                 SdButton(scr, "ok",   1, 16, 29, 10, "Maint", "m", 1);
  191.             }
  192.             else {
  193.                 SdModeSet(scr, 1);
  194.                 SdModeSet(scr, 0, "code", "del");
  195.                 if (univ^clbr_code^[client]^[code])
  196.                     SdButton(scr, "ok",   1, 16, 29, 10, "Modify", "m", 1);
  197.                 else
  198.                     SdButton(scr, "ok",   1, 16, 29, 10, "Add", "a", 1);
  199.             }
  200.             SdFieldVar(scr, "code",     code,
  201.                             "desc",     &univ^clbr_code^[client]^[code],
  202.                             "attn",     &univ^clbr^[client]^[code]^attn,
  203.                             "add1",     &univ^clbr^[client]^[code]^add1,
  204.                             "add2",     &univ^clbr^[client]^[code]^add2,
  205.                             "add3",     &univ^clbr^[client]^[code]^add3,
  206.                             "add4",     &univ^clbr^[client]^[code]^add4);
  207.         }
  208.         cmd = SdEdit(scr, cursor);
  209.         if (mode) {
  210.             Explode(SdFieldGet(scr, "code"), "^", &code);
  211.             if (cmd == 133)             /* action on the combo box */
  212.                 continue;
  213.             else if (cmd == 2 || cmd == 3)
  214.                 break;
  215.             else if (cmd != 1) {
  216.                 if (!univ^clbr_code^[client]^[code]) {
  217.                     MsgWait("", "Client Code does not exist.");
  218.                     continue;
  219.                 }
  220.                 if (cmd == 114) {       /* delete */
  221.                     if ((cmd = MsgYesNoCancel("", 
  222.                                 "Delete " . code . ", are you sure ?")) 
  223.                         && cmd == 2)        /* yes hit ? */
  224.                         ClientBranchDelete(client, code);
  225.                 }
  226.                 continue;
  227.             }
  228.             mode = 0;                   /* means change details */
  229.         }
  230.         else {
  231.             if (cmd == 1) {
  232.                 if (!SdFieldGet(scr, "desc")) {
  233.                     MsgWait("", "A description must be entered.");
  234.                     cursor = "desc";
  235.                     continue;
  236.                 }
  237.                 SdUpdate(scr);
  238.             }
  239.             else if (cmd == 3)
  240.                 break;
  241.             mode = 1;                   /* means do next selection */
  242.         }
  243.         cursor = "";
  244.     }
  245.     SdDestroy(scr);
  246. }
  247.  
  248.